<?php /*a:1:{s:54:"D:\crm\application\crm\view\product\course\upload.html";i:1670312059;}*/ ?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/static/crm/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/crm/css/public.css" media="all">
    <title>Document</title>
</head>

<body>
    <div class="layui-container">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">上传</label>
                <div class="layui-input-block">
                    <input id="file" type="text" name="title" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <button type="button" class="layui-btn" id="test1">
                    <i class="layui-icon">&#xe67c;</i>上传导入文件：
                </button>
                *请按照模板填好批量上传 <a href="download" style="color:brown">点击下载模板</a>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</body>

</html>

<script src="/static/crm/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>

<script>
    layui.use(['jquery', 'layer', 'form', 'upload'], function () {
        var $ = layui.jquery
            , layer = layui.layer
            , form = layui.form
            , upload = layui.upload

        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            , url: 'uploading' //上传接口
            , exts: 'xlsx'
            , done: function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg);
                    $('#file').val(res.data['file']);
                }
                layer.msg(res.msg);
            }
            , error: function () {
                //请求异常回调
            }
        });

        form.on('submit(formDemo)', function (data) {
            $.ajax({
                url: 'uploadingSql',
                type: 'post',
                dataType: 'json',
                data: data.field,
                success: function (data) {
                    if (data.code == 1) {
                        layer.msg(data.msg, {
                            time: 1500,
                            end: function () {
                                var iframeIndex = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(iframeIndex);
                            }
                        });
                    } else if (data.code == 0) {
                        layer.msg(data.msg);
                    }
                }
            });
            return false;
        });
    });
</script>